home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14986 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  833 b 

  1. Path: lisa.cs.mcgill.ca!milosz
  2. From: milosz@cs.mcgill.ca (Jean-Luc MANIGAT)
  3. Newsgroups: comp.lang.c++
  4. Subject: Pointers to functions
  5. Date: 3 Apr 1996 00:44:46 GMT
  6. Organization: SOCS, McGill University, Montreal, Canada
  7. Message-ID: <4jshlu$sv9@lisa.cs.mcgill.ca>
  8. NNTP-Posting-Host: willy.cs.mcgill.ca
  9.  
  10. Say you have a function that takes a function for an argument:
  11.  
  12. void print(int (*f)(int, int), int a, int b) {
  13.     cout << f(a, b);
  14. }
  15.  
  16. Fine, but in "More C++ in 21 days", when they used a some member 
  17. function, they did something like:
  18.  
  19. void print(int (X::*f)(), X& x) {
  20.     cout << x.*f();
  21. }
  22.  
  23. Now how come you have to dereference the pointer in one case, and not in 
  24. the other? I've tried doing cout << x.f(); and it doesn't work.
  25.  
  26. E-Mail replies greatly appreciated.
  27.  
  28. -- 
  29.     J
  30.  
  31. - Mamo, dlaczego ten Murzyn tak pije?
  32. - Bo chce mu sie pic.
  33.